package com.itany.controller;

import com.github.pagehelper.PageInfo;
import com.itany.pojo.Role;
import com.itany.service.RoleService;
import com.itany.vo.PermissionTree;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Author：sl
 * Date：2019-09-26 下午4:53
 * Description：<描述>
 */
@RequestMapping("/role")
@Controller
public class RoleController {

    @Autowired
    RoleService roleService;


    @RequestMapping("/findAllRole")
    @ResponseBody
    public Map<String, Object> findAllPermission(@RequestParam(defaultValue = "1") Integer page,
                                                 @RequestParam(defaultValue = "5") Integer rows) {

        Map<String, Object> map = new HashMap<String, Object>();
        PageInfo<Role> info = roleService.findAllPermission(page, rows);
        map.put("total", info.getTotal());
        map.put("rows", info.getList());
        return map;

    }


    @RequestMapping("/findAllPermissionTree")
    @ResponseBody
    public List<PermissionTree> findAllPermissionTree() {
        List<PermissionTree> list=roleService.findAllPermissionTree();
        return list;
    }

    @RequestMapping("modifyById")
    public String modifyById(Role role,@Param("ids") String ids) {

        /**
         * 没做
         */
        System.out.println(role);
        System.out.println(ids);

        return "backend/role";
    }
}
